#!/usr/bin/env python3
import sys
import os
import xml.etree.ElementTree as ET

class flow_queue_class:
    def __init__():
        self.queue = []

class flow_step_class( type ):
    def __init__():
        self.type = type

def read_flow_xml( xml_file ):
    setup_variables = {}
    xml_tree = ET.parse( xml_file )
    xml_root = xml_tree.getroot()
    ### Read /flow/setup/variables
    for xml_variable in xml_root.findall('./setup/variables/*'):
        xml_variable_name  = xml_variable.findall('./name')[0].text
        xml_variable_type  = xml_variable.findall('./value')[0].attrib.get('type')
        xml_variable_value = xml_variable.findall('./value')[0].text
        if xml_variable_type == 'env' :
            env_variable_name  = xml_variable_value
            xml_variable_value = os.getenv(env_variable_name)
        setup_variables[xml_variable_name] = xml_variable_value
    return setup_variables
    

def main():
    setup_variables = read_flow_xml( 'flow.xml' )
    for var_name in sorted(setup_variables.keys()) :
        print( var_name+" : "+setup_variables[var_name] )
    
if __name__ == "__main__":
    main()